import router from './router'
import Nprogress from 'nprogress'
import Store from '@/store'
import 'nprogress/nprogress.css'
const whileList = ['/login', '/404']
// 前置路由守卫
router.beforeEach((to, from, next) => {
  Nprogress.start()

  Store.getters.token
    ? to.path === '/login' ? next('/') : next()
    : whileList.includes(to.path) ? next() : next('/login')
  Nprogress.done()
})
// 后置路由守卫
router.afterEach((to) => {
  Nprogress.done()
})
